docker pull mysql
# 新增挂载文件夹
mkdir -p /mydata/mysql/log
mkdir -p /mydata/mysql/data
mkdir -p /mydata/mysql/conf


cd /mydata/mysql/conf

echo '[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
init_connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
#忽略客户端信息并使用默认服务器字符集
skip-character-set-client-handshake
#禁止DNS解析
skip-name-resolve
#限制LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE()传到哪个指定目录
secure_file_priv=/var/lib/mysql' >> my.cnf


docker run -p 3308:3306  \
            --name mysql \
            -v /mydata/mysql/log:/var/log/mysql \
            -v /mydata/mysql/data:/var/lib/mysql \
            -v /mydata/mysql/conf:/etc/mysql \
            -e MYSQL_ROOT_PASSWORD=root123 \
            -d mysql
docker exec -it  mysql /bin/bash